package com.mofang.powerdekorhelper.utils;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;

import com.mofang.powerdekorhelper.R;

import pl.tajchert.waitingdots.DotsTextView;

/**
 * Created by luofei on 2017/8/18 0018.
 */

public class LoadPrograss {

    DotsTextView dots;

    Activity mContext;

    Dialog loadDialog;

    public LoadPrograss(Activity mContext) {
        this.mContext = mContext;
        initDots();
    }

    private void initDots() {
        loadDialog = MyProgressDialog(mContext);
    }

    public void show() {

        loadDialog.show();
        dots.showAndPlay();
    }

    public void hide() {

        loadDialog.dismiss();
        dots.hideAndStop();
    }

    /**
     * loading...
     */
    public Dialog MyProgressDialog(Context context) {
        View view = LayoutInflater.from(context).inflate(R.layout.load_prograss_layout, null);
        dots = (DotsTextView) view.findViewById(R.id.waitingdots_load);
        Dialog loadDialog = new Dialog(context, R.style.loading_dialog);
        loadDialog.setCanceledOnTouchOutside(false);
        LinearLayout.LayoutParams params = null;
        loadDialog.setContentView(view);
        return loadDialog;
    }
}
